// 以下代码是配置layui扩展模块的目录，每个页面都需要引入
layui.config({
    base: getProjectUrl()
}).extend({
    index: 'lib/index', //主入口模块
    //公共插件
    formSelects: 'common/formSelects/formSelects-v4',
    treetable: 'common/treetable-lay/treetable',
    dropdown: 'dropdown/dropdown',
    tableSelect: 'common/tableSelect/tableSelect',
    treeGrid:'common/tree-grid/treeGrid',
    treeSelect: 'common/treeSelect/treeSelect',
    xmSelect: 'common/xmSelect/xm-select',
    myTinyMce:'common/tinymce/myTinyMce',
    eleTree:'common/eleTree/eleTree',

    //系统管理
    dict:'system/dict',
    menu:'system/menu',
    role:'system/role',
    useradmin:'system/useradmin',

    //内容管理
    article:'cms/article',
    category:'cms/category'
});

// 获取当前项目的根路径，通过获取layui.js全路径截取assets之前的地址
function getProjectUrl() {
    var layuiDir = layui.cache.dir;
    if (!layuiDir) {
        var js = document.scripts, last = js.length - 1, src;
        for (var i = last; i > 0; i--) {
            if (js[i].readyState === 'interactive') {
                src = js[i].src;
                break;
            }
        }
        var jsPath = src || js[last].src;
        layuiDir = jsPath.substring(0, jsPath.lastIndexOf('/') + 1);
    }
    return layuiDir;
}
